//
//  UIWindow+Extension.m
//  CreditManger
//
//  Created by chaiyanan on 15/11/10.
//  Copyright © 2015年 jinxin. All rights reserved.
//

#import "UIWindow+Extension.h"
#import "CMNavigationController.h"
#import "CMLoginManager.h"
#import "CMHomeCtrl.h"
#import "CMLoginCtrl.h"

@implementation UIWindow (Extension)

- (void)switchRootViewController
{
    [self changeRootCtrlWithUser];
}
/**
 *  根据用户的登陆状态 决定选择哪一个页面
 */
-(void)changeRootCtrlWithUser
{
    [CMLoginManager getCurrentUserFromUserdefault];
    
    if ([CMLoginManager sharedCMLoginManager].hasLogined)
    {
        CMHomeCtrl *home = [[CMHomeCtrl alloc]init];
        self.rootViewController = [[CMNavigationController alloc]initWithRootViewController:home];
    }
    else
    {
        CMLoginCtrl *login = [[CMLoginCtrl alloc]init];
        CMNavigationController *nav = [[CMNavigationController alloc]initWithRootViewController:login];
        [nav setNavigationBarHidden:YES];
        self.rootViewController = nav;
    }
    
}

@end
